<?php
include('include/config.php');

define('TABLEPREFIX',$database['tableprefix']);
define('DB_HOST',$database['host']);
define('DB_POST',$database['port']);
define('DB_USERNAME',$database['username']);
define('DB_PASSWORD',$database['password']);
define('DB_DATABASE',$database['database']);

define('SESSION_MODE',(strtolower($session['mode']) == 'cookie' ? 'cookie' : 'session'));
define('SESSION_PREFIX',$session['prefix']);


include('include/core.php');
include('include/user.php');
include('include/template.php');
include('include/language.php');
include('include/database/database.php');
include('include/database/'.$database['type'].'.php');
include('include/session.php');



$core = new Core();
$session = new Session();

if ($session->get('userid') && $session->get('REMOTE_ADDR') == $_SERVER['REMOTE_ADDR'])
{
    $user = new User($session->get('userid'));
    $loggedin = $session->loggedin($user);
    if ($loggedin)
    {
        $language = new Language($user->get('language'));
        define('LOGGEDIN',TRUE);
    }
    else
    {
        $language = new Language($core->get('defaultlanguage'));
        define('LOGGEDIN',FALSE);
    }
}
else
{
    $language = new Language($core->get('defaultlanguage'));
    define('LOGGEDIN',FALSE);
}
?>